<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/

get_config_keytable("istration_conference");

empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = 20;
	$offset = ($page - 1) * $pagesize;
	$url = 'admin.php?ac=index&fileurl=conference&type='.$_GET[type].'';

	if ($keyword = getGP('keyword','G')) {
		$wheresql .= " AND (title LIKE '%$keyword%' or subject LIKE '%$keyword%')";
		$url .= '&keyword='.rawurlencode($keyword);
	}
	if ($conferenceroom = getGP('conferenceroom','G','int')) {
		$wheresql .= " AND conferenceroom ='".$conferenceroom."'";
		$url .= '&conferenceroom='.$conferenceroom;	
	}
	//时间
	$vstartdate = getGP('vstartdate','G');
	$venddate = getGP('venddate','G');
	if ($vstartdate!='' && $venddate!='') {
		$wheresql .= " AND (date>='".$vstartdate."' and date<='".$venddate."')";
	$url .= '&vstartdate='.$vstartdate.'&venddate='.$venddate;
	}
	//员工
	if ($user = getGP('user','G','int')) {
		$wheresql .= " AND appperson ='".$user."'";
		$url .= '&user='.$user;	
	}
	//待我参加的会议
	if (getGP('contype','G')=='key1') {
		$wheresql .= " AND attendance LIKE '%".GET_INC_USER_NAME($_USER->id)."%'";
	}
	//我己参加的会议
	if (getGP('contype','G')=='key2') {
		$wheresql .= " AND attendance LIKE '%".GET_INC_USER_NAME($_USER->id)."%' and enddate<='".get_date('Y-m-d H:i:s',PHP_TIME)."'";
	}
	//待开会议查询
	if (getGP('contype','G')=='key3') {
		$wheresql .= " AND attendance LIKE '%".GET_INC_USER_NAME($_USER->id)."%' and startdate>='".get_date('Y-m-d H:i:s',PHP_TIME)."'";
	}
	//己开会议查询
	if (getGP('contype','G')=='key4') {
		$wheresql .= " AND attendance LIKE '%".GET_INC_USER_NAME($_USER->id)."%' and startdate<='".get_date('Y-m-d H:i:s',PHP_TIME)."'";
	}
	$url .= '&contype='.getGP('contype','G');
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."conference WHERE 1 $wheresql");
     $sql = "SELECT * FROM ".DB_TABLEPRE."conference WHERE 1 $wheresql ORDER BY id desc LIMIT $offset, $pagesize";
	$result = $db->fetch_all($sql);

	include_once('template/index.php');

} elseif ($do == '删 除') {

get_config_keytable("istration_conference_delete");
	$idarr = getGP('id','P','array');
	foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."conference WHERE id = '$id'");
	//db->query("DELETE FROM ".DB_TABLEPRE."user_view WHERE uid = '$id'");
	$content=$id;
	$title='删除会议信息';
	get_oa_log_dbadd($id,$content,$title,19,$_USER->id);
	}
	goto_page('admin.php?ac=index&fileurl=conference&message=1&type='.$_GET[type].'');

} 


//读部门

?>